package com;// FILEPATH: D:/test/FightSys/src/Main.java

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Log {
    // 定义日志级别
    public static final int LOG_LEVEL_DEBUG = 0;
    public static final int LOG_LEVEL_INFO = 1;
    public static final int LOG_LEVEL_WARN = 2;
    public static final int LOG_LEVEL_ERROR = 3;

    // 当前日志级别，可以根据需要调整
    public static final int CURRENT_LOG_LEVEL = LOG_LEVEL_DEBUG;

    // 日志方法
    public static void log(int level, Object... args) {
        if (level >= CURRENT_LOG_LEVEL) {
            String levelStr;
            switch (level) {
                case LOG_LEVEL_DEBUG: levelStr = "DEBUG"; break;
                case LOG_LEVEL_INFO:  levelStr = "INFO"; break;
                case LOG_LEVEL_WARN:  levelStr = "WARN"; break;
                case LOG_LEVEL_ERROR: levelStr = "ERROR"; break;
                default: levelStr = "UNKNOWN"; break;
            }

            String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
            StringBuilder message = new StringBuilder();
            for (Object arg : args) {
                message.append(arg).append(" ");
            }

            System.out.printf("%s [%s]: %s%n", timestamp, levelStr, message.toString().trim());
        }
    }

    // 定义日志宏
    public static void Debug(Object... args) {
        log(LOG_LEVEL_DEBUG, args);
    }

    public static void LINFO(Object... args) {
        log(LOG_LEVEL_INFO, args);
    }

    public static void LWARN(Object... args) {
        log(LOG_LEVEL_WARN, args);
    }

    public static void Error(Object... args) {
        log(LOG_LEVEL_ERROR, args);
    }


}